import App from './App.vue'
import router from './router'
import store from './store/index'
import Vodal from 'vodal'
import VueCropper from 'vue-cropper'
import 'vodal/common.css'
import 'vodal/zoom.css'
import 'vue2-toast/lib/toast.css'
import Toast from 'vue2-toast'
import './common/configHttp.js'
import deviceInfo from './common/deviceInfo'
import './common/rem'
import * as filters from './common/filters'
import api from './api'
import './css/reset.css' // 全局css重置
import './css/public.css' // 全局公用css class
import './css/animate.css' // 全局公用css动画效果
import './directives/ElScroll'
import './directives/InputDelete'
import './directives/InputBlur'
import './directives/TextareaDelete'
import './directives/Touch'
import infiniteScroll from 'vue-infinite-scroll'
import visibility from 'vue-visibility-change'
import * as utils from './common/utils'

if (process.env.NODE_ENV === 'development') {
  Vue.config.devtools = true
}

if (!deviceInfo().isPhone) {
  // 非手机端 并且不是iframe嵌套
  if (window.self === window.top) {
    window.location.href = process.env.VUE_APP_PC_DOMAIN
  }
}

Vue.config.productionTip = false

// 全局引入modal插件
Vue.component(Vodal.name, Vodal)

//全局引入swiper
Vue.use(VueAwesomeSwiper)
Swiper2.use([Navigation, Pagination, EffectFade, Autoplay])

Vue.use(VueCropper)

Vue.use(infiniteScroll)

Vue.use(visibility)

Vue.use(Toast, {
  type: 'center',
  duration: 2000,
  wordWrap: true,
  width: 'auto',
})
// 全局滤镜
Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key])
})

// 返回不刷新 针对 ios
utils.backRefresh()

// 后台api接口 全局注册
Vue.use(api)

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app')
